﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/4/2009
 * Time: 12:03 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NHibernate;
using System.Collections.Generic;
using System.Data;
using PilotFish.Model.Dao.Interface;

namespace PilotFish.Model.Dao.NHibernate
{
	/// <summary>
	/// Description of NHibernateDoctorDao.
	/// </summary>
	public class NHibernateDoctorDao : IDoctorDao
	{
		public NHibernateDoctorDao()
		{
		}
		
		public void SaveOrUpdate(Doctor doctor)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.SaveOrUpdate(doctor);
			session.Flush();
		}
		
		public void Delete(Doctor doctor)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.Delete(doctor);
			session.Flush();
		}
		
		public Doctor ReadByPk(int id)
		{
			return NHibernateHelper.OpenSession().Load<Doctor>(id);
		}
		
		public IList<Doctor> FindAll()
		{
			return NHibernateHelper.OpenSession().CreateCriteria(typeof(Doctor)).List<Doctor>();
		}
	}
}
